package sumbytype;

import java.io.IOException;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

public class PairMapper extends Mapper<Object, Text, CompositeKey, IntWritable>{

    private CompositeKey outKey = new CompositeKey();
    private IntWritable outValue = new IntWritable(1);
    
    public void map(Object key, Text value, Context context) 
            throws IOException, InterruptedException {
        String[] str = value.toString().split(",");
        
        String line = str[1].substring(2);
        String date = str[5].substring(0, 8);
        String type = str[6];
        outKey.setLine(Integer.parseInt(line));
        outKey.setDate(Integer.parseInt(date));
        outKey.setType(type);
        
        context.write(outKey, outValue);
        
    }
    
}